home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1991: Code Warrior / bincue / Code Warrior.bin / Tools & Apps (Moof!) / OS⁄Toolbox / HyperMenus / AppendMenu.c next >
Encoding:
Text File  |  1990-07-23  |  1.0 KB  |  67 lines  |  [TEXT/MPS ]

  1. //
  2. //        © Copyright 1990 Apple Computer, Inc.   By Ricardo Batista
  3. //
  4.  
  5. #include "Types.h"
  6. #include "Memory.h"
  7. #include "Menus.h"
  8. #include "Packages.h"
  9. #include "HyperXCMD.h"
  10.  
  11.  
  12. void GetHLong(Handle H, long *s);
  13. void GetHString(Handle H, char *s);
  14.  
  15. pascal void MAIN(XCmdPtr xcmd)
  16. {
  17.     char data[255];
  18.     long num;
  19.     
  20.     if (xcmd->paramCount != 2)
  21.         return;
  22.     GetHLong(xcmd->params[0], &num);
  23.     if (!num)
  24.         return;
  25.     GetHString(xcmd->params[1], data);
  26.     AppendMenu((MenuHandle) num, data);
  27. }
  28.  
  29.  
  30. void GetHLong(Handle H, long *s)
  31. {
  32.     short len;
  33.     char st[256];
  34.     
  35.     *s = 0L;
  36.     HLock(H);
  37.     len = (short) GetHandleSize(H);
  38.     if (len > 255)
  39.         len = 255;
  40.     BlockMove(*H, &st[1], (long) len);
  41.     HUnlock(H);
  42.     len = 1;
  43.     while (st[len])
  44.         len++;
  45.     st[0] = len - 1;
  46.     StringToNum(st, s);
  47. }
  48.  
  49.  
  50.  
  51. void GetHString(Handle H, char *s)
  52. {
  53.     short len;
  54.     char st[256];
  55.     
  56.     HLock(H);
  57.     len = (short) GetHandleSize(H);
  58.     if (len > 255)
  59.         len = 255;
  60.     BlockMove(*H, &st[1], (long) len);
  61.     HUnlock(H);
  62.     len = 1;
  63.     while (st[len])
  64.         len++;
  65.     st[0] = len - 1;
  66.     BlockMove(st, s, (long) len);
  67. }